package com.shopping.mall.core.module.ipAddress.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;

import java.sql.Timestamp;
import java.util.Date;
import java.util.Map;

/**
* IpAddress实体类
*
* @author zzy
* @date 2021-08-30
*/
@Data
@TableName("ip_address")
public class IpAddressVO {

    public interface insert{
    }

    public interface update{
    }

    @ApiModelProperty(value="主键")
    @TableId(type = IdType.UUID)
    private String id;

    @ApiModelProperty(value="IP")
    private String ip;

    @ApiModelProperty(value="来源")
    private String source;

    @ApiModelProperty(value="访问地址")
    private String url;

    @ApiModelProperty(value="国家")
    private String country;

    @ApiModelProperty(value="省")
    private String province;

    @ApiModelProperty(value="市")
    private String city;

    @ApiModelProperty(value="区")
    private String district;

    @ApiModelProperty(value="创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp createAt;

    @ApiModelProperty(value="修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp updateAt;

    @TableField(exist = false)
    @ApiModelProperty(value="时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Timestamp time;

    @ApiModelProperty(value = "开始日期")
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date before;

    @ApiModelProperty(value = "结束日期",dataType = "java.sql.Date")
    @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date after;

    public void setPlace(Map<String, Object> result) {
        this.country= (String) result.get("country");
        this.province= (String) result.get("province");
        this.city= (String) result.get("city");
        this.district= (String) result.get("district");
    }
}
